| Conditions | 1 |
| Paths | 1 |
| Total Lines | 75 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var PBSyntaxHighlighter = (function() { |
||
| 2 | "use strict"; |
||
| 3 | |||
| 4 | var sh; |
||
| 5 | |||
| 6 | /** |
||
| 7 | * Constructor |
||
| 8 | * @param {String} sh The SyntaxHighlighter |
||
| 9 | */ |
||
| 10 | function PBSyntaxHighlighter(sh) { |
||
| 11 | switch (sh) { |
||
| 12 | case "HIGHLIGHT" : |
||
| 13 | this.sh = HIGHLIGHT; |
||
| 14 | break; |
||
| 15 | case "PRETTIFY" : |
||
| 16 | this.sh = PRETTIFY; |
||
| 17 | break; |
||
| 18 | case "PRISM" : |
||
| 19 | this.sh = PRISM; |
||
| 20 | break; |
||
| 21 | case "SYNTAX_HIGHLIGHTER" : |
||
| 22 | this.sh = SYNTAX_HIGHLIGHTER; |
||
| 23 | break; |
||
| 24 | default : |
||
| 25 | this.sh = { |
||
| 26 | _type: "DEFAULT", |
||
| 27 | _cls: "", |
||
| 28 | _tag: 'pre' |
||
| 29 | }; |
||
| 30 | break; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Sets the SyntaxHighlighter type |
||
| 36 | * @param {String} type The name of the SyntaxHighlighter |
||
| 37 | */ |
||
| 38 | PBSyntaxHighlighter.prototype.setType = function(type) { |
||
| 39 | this.sh._type = type; |
||
| 40 | }; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Gets the SyntaxHighlighter type |
||
| 44 | * @return {String} The type of the SyntaxHighlighter |
||
| 45 | */ |
||
| 46 | PBSyntaxHighlighter.prototype.getType = function() { |
||
| 47 | return this.sh._type; |
||
| 48 | }; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Sets the full class of the SH object |
||
| 52 | * @param {String} cls the class to add to the Object |
||
| 53 | */ |
||
| 54 | PBSyntaxHighlighter.prototype.setCls = function(cls) { |
||
| 55 | this.sh.cls = this.sh._cls + cls; |
||
| 56 | }; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Gets the full class of the SH Object |
||
| 60 | * @return {String} the full class of the SH Object |
||
| 61 | */ |
||
| 62 | PBSyntaxHighlighter.prototype.getCls = function() { |
||
| 63 | return this.sh.cls; |
||
| 64 | }; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Get the tag to insert into the pre tag |
||
| 68 | * @return {String} the tag to insert, pre otherwise |
||
| 69 | */ |
||
| 70 | PBSyntaxHighlighter.prototype.getTag = function() { |
||
| 71 | return this.sh._tag; |
||
| 72 | }; |
||
| 73 | |||
| 74 | return PBSyntaxHighlighter; |
||
| 75 | })(); |
||
| 76 | |||
| 103 |